package com.lc.learn;


import com.lc.learn.constant.SocketConstant;
import com.lc.learn.netty.server.NettyServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.Resource;
import java.net.InetSocketAddress;


@Slf4j
@SpringBootApplication
public class NettyApplication implements CommandLineRunner {

    @Resource
    private NettyServer nettyServer;

    public static void main(String[] args) {
        SpringApplication.run(NettyApplication.class, args);
    }

    /**
     * 启动时启动Netty服务端
     */
    @Override
    public void run(String... args) throws Exception {
        InetSocketAddress inetSocket = new InetSocketAddress(SocketConstant.HOST, SocketConstant.PORT);
        log.info("netty服务器启动-->{}:{}", SocketConstant.HOST, SocketConstant.PORT);
        nettyServer.start(inetSocket);
    }
}
